﻿using Landpy.CruiseControlNet.ConfigurationSidekick.ConfigTreeModule;
using Landpy.CruiseControlNet.ConfigurationSidekick.ParserModule;

namespace Landpy.CruiseControlNet.ConfigurationSidekick.ConfigPropertyModule
{
    class SubjectHandler : GetPropertiesHandler
    {
        public override object GetPropertiesObject(GetPropertiesContext getPropertiesContext)
        {
            var treeNodeIndentity = this.GetTreeNodeIndentity(getPropertiesContext);
            if (treeNodeIndentity.Type == TreeNodeType.Subject)
            {
                SubjectKey subjectKey = SubjectKeyUtil.GetKey(treeNodeIndentity.Key);
                return this.SubjectRepository.GetSubjectById(getPropertiesContext.CruiseControl, subjectKey.ProjectId,
                                                             subjectKey.PublisherId, subjectKey.Id);
            }
            return this.Successor.GetPropertiesObject(getPropertiesContext);
        }
    }
}
